define("leaflet/heatlayer", ["leaflet"], function(L) {

    L.TileLayer.HeatLayer = L.TileLayer.extend({

        getTileUrl: function(coords) {
            var data = {
                x: this.getHexString(coords.y),
                y: this.getHexString(coords.x),
                z: coords.z >= 10 ? coords.z : '0' + coords.z
            };
            return L.Util.template(this._url, data);
        },

        getHexString: function(value) {
            var strHex = value.toString(16);
            switch (strHex.length) {
                case 1:
                    strHex = "0000000" + strHex;
                    break;
                case 2:
                    return strHex = "000000" + strHex;
                    break;
                case 3:
                    strHex = "00000" + strHex;
                    break;
                case 4:
                    strHex = "0000" + strHex;
                    break;
                case 5:
                    strHex = "000" + strHex;
                    break;
                case 6:
                    strHex = "00" + strHex;
                    break;
                case 7:
                    strHex = "0" + strHex;
                    break;
                default:
                    ;
            }
            return strHex;
        }
    });

    L.tileLayer.heatLayer = function(url, options) {
        return new L.TileLayer.HeatLayer(url, options);
    };

});
